import { type } from 'os';
import { MAIN } from '../constants';
import { HlAllData, HlSectData, EdrmsTypeDto } from '@/services/types';

export interface MainState {
  curTab: string;
  allData?: HlAllData;
  zbData?: HlSectData;
  jyData?: HlSectData;
  mkhData?: HlSectData;
  edrmsTypeDto?: EdrmsTypeDto
}

const initMainState: MainState = {
  curTab: 'all',
  edrmsTypeDto: {
    "total": 0,
    "edrmsTypeData": [
      {
        "sort": 0,
        "name": "",
        "number": 0,
        "perCentNumber": 0
      },

    ]
  }
  // allData: {
  //   biOverviewDto: {
  //     archNum: 0,
  //     digitizationRate: 0,
  //     dossierNum: 0,
  //     electronicsArchNum: 0,
  //     entityArchNum: 0,
  //     fileTotalSize: 0,
  //     monthAddFileSizeNum: 0,
  //     sectNum: 0,
  //     totalArchNum: 0,
  //     yearAddArchNum: 0,
  //     yearAddFileSizeNum: 0,
  //   },
  //   borrowNumList: [],
  //   borrowOrderList: [],
  //   sectArchOrderDescList: [],
  //   sectLocal: [],
  // },
};

const main = (state = initMainState, action: { type: MAIN; payload: any }) => {
  switch (action.type) {
    case MAIN.SET_TAB:
      return { ...state, curTab: action.payload.curTab };
    case MAIN.GET_ALL_DATA:
      return Object.assign({}, state);
    case MAIN.SET_ALL_DATA:
      return { ...state, allData: action.payload.allData };
    case MAIN.GET_SECT_DATA:
      return Object.assign({}, state);
    case MAIN.SET_SECT_DATA:
      return { ...state, [action.payload.sectData.sectName]: action.payload.sectData.value };
    case MAIN.GET_EDRM_TYPE:
      console.log(action.payload.edrmsTypeDto)
      return { ...state, edrmsTypeDto: action.payload.edrmsTypeDto };


    default:
      return state;
  }
};

export default main;
